#pragma once

#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/interprocess/containers/string.hpp>
#include <boost/interprocess/managed_shared_memory.hpp>

namespace bip = boost::interprocess;

// 字符串分配器和类型
typedef bip::allocator<char, bip::managed_shared_memory::segment_manager>
    CharAllocator;
typedef bip::basic_string<char, std::char_traits<char>, CharAllocator>
    SharedString;

// 自定义类
struct Person {
  int age;
  float height;
  SharedString name;

  // 构造函数需要带 allocator
  Person(int age_, float height_, const SharedString &name_)
      : age(age_), height(height_), name(name_) {}
};
